/*
 * LineRing
 * 
 * initial implementation : 4.9.2007
 *
 * Copyright (c) Adam Sida, asida@centrum.cz.
 * All rights reserved.
 * 
 * for license see Petra.Gis.License.txt
 */
using System;
//using System.Collections.Generic;
//using System.Text;
using Petra.Gis.Geometry.Support;


namespace Petra.Gis.Geometry
{
  /// <summary>
  /// LineRing is simple polygon (closed polyline or linestring) with following exception
  /// SFS relies on linestring but linestring is not area geometry type as should be
  /// LineRing must contain at least 4 points and LastPoint == FirstPoint
  /// </summary>
  public class LineRing : Surface
  {
    private CoordinateList _CoordinateList;



    static LineRing()
    {
      //sGeometryType = GeometryTypes.LINERING_GEOMETRY;
    }




    public CoordinateList coordList
    {
      get { return _CoordinateList; }
      set
      {
        if (value.Count < 4)
          throw new ArgumentException("coordList for " + this.GetType().ToString() + " must have at least 4 points");
        //last point must be same as first
        if (!value.startPoint.Equals(value.endPoint, value.dimension))
          throw new ArgumentException("coordList for " + this.GetType().ToString() + " endPoint != startPoint");
        _CoordinateList = value;
      }
    }




    internal override BoundingBox getEnvelope()
    {
      _envelope = _CoordinateList.getEnvelope();
      return _envelope;
    }
  }
}
